﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;

namespace NJL.Web
{
    public partial class LocalColor : BasePageVisitor
    {
        protected readonly BLL.NJL_LOCAL_COLOR bll = new BLL.NJL_LOCAL_COLOR();
        private readonly BLL.NJL_SYS_NEWS bllSysNews = new BLL.NJL_SYS_NEWS();
        private readonly BLL.NJL_CS_LOCAL_COLOR_TYPE bllLocaltype = new BLL.NJL_CS_LOCAL_COLOR_TYPE();
        private readonly BLL.NJL_CS_TAG bllTag = new BLL.NJL_CS_TAG();
        private readonly BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();

        protected IList<Model.NJL_LOCAL_COLOR> LIST_1;
        protected IList<Model.NJL_LOCAL_COLOR> LIST_2;
        protected IList<Model.NJL_LOCAL_COLOR> LIST_3;
        protected IList<Model.NJL_LOCAL_COLOR> LIST_4;

        protected IList<Model.NJL_SYS_NEWS> LIST_FLASH;
        protected IList<Model.NJL_CS_LOCAL_COLOR_TYPE> modelColortype;

        protected IList<Model.NJL_CS_TAG> LIST_TAG;
        protected IList<Model.NJL_NEWS> LIST_NEWS;

        DataSet ds = new DataSet();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtKeywords.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Button1.ClientID + "').click();return false;}} else {return true}; ");
            }
                LoadData();
                base.LoadPageSeoInformation("地方特色");
            
        }
        private void LoadData()
        {
            LIST_FLASH = bllSysNews.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 AND IS_INDEX=1 AND TYPE_CODE='14' ", "PUBLISH_DATE_TIME DESC");

            //
            //LIST_1 = bll.GetModelList(8, " AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " ID desc");
            //LIST_2 = bll.GetModelList(4, " AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " ID desc");
            //LIST_3 = bll.GetModelList(6, " AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " ID desc");
            //LIST_4 = bll.GetModelList(8, " AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " ID desc");
            //
            modelColortype = bllLocaltype.GetModelList("");

            #region 地方特色类型
            ds = bllLocaltype.GetList("");
            rptLocalType.DataSource = ds;
            rptLocalType.DataBind();
            #endregion

            #region 标签
            if (WEBSITE_FOCUS_CITY_CODE != "")
            {
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='2' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "SEARCH_COUNT desc,USED_COUNT DESC");
            }
            else
            {
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='2'", "SEARCH_COUNT desc,USED_COUNT DESC");
            }
            #endregion

            #region 热点热评
            LIST_NEWS = bllNews.GetModelList(6, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "CREATE_DATE_TIME DESC");
            #endregion

            #region 咨询
            ds = bllSysNews.GetList(8, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  TYPE_CODE='17' and IS_PUBLISH=1 AND IS_INDEX=1 ", "SORT DESC,PUBLISH_DATE_TIME desc");
            rptNews.DataSource = ds;
            rptNews.DataBind();
            #endregion
            #region 本季特色
            NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
            if (WEBSITE_FOCUS_CITY_CODE != "")
            {
                ds = bllService.GetList(3, "NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "') and IMAGE_CODE is not null", "SORT DESC,CREATE_DATE_TIME desc");
            }
            else
            {
                ds = bllService.GetList(3, "NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "') and IMAGE_CODE is not null", "SORT DESC,CREATE_DATE_TIME desc");
            }
            rptService.DataSource= ds;
            rptService.DataBind();
            #endregion
            #region 周边同类
            if (WEBSITE_FOCUS_CITY_CODE != "")
            {
                ds = bll.GetList(4, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE!='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " SORT DESC,CREATE_DATE_TIME desc");
            }
            else
            {
                ds = bll.GetList(4, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", " SORT DESC,CREATE_DATE_TIME desc");
            }
            rptOtherColor.DataSource = ds;
            rptOtherColor.DataBind();
            #endregion
            #region 热门景点
            NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
            if (WEBSITE_FOCUS_CITY_CODE != "")
            {
                ds = bllAttr.GetList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1", "SORT DESC,CREATE_DATE_TIME desc");
            }
            else
            {
                ds = bllAttr.GetList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1", "SORT DESC,CREATE_DATE_TIME desc");
            }
            rptHot.DataSource = ds;
            rptHot.DataBind();
            #endregion
        }

        protected void rptLocalType_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal lit = e.Item.FindControl("typecss") as Literal;
                if (e.Item.ItemIndex == 0)
                {
                    lit.Text = "now";
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/SearchLocalColor.aspx?keywords=" + txtKeywords.Text.Trim() + "&cc=" + WEBSITE_FOCUS_CITY_NAME_PINYIN);
        }

    }
}